function addSizeBreakup(control_obj,size_type_control)
{
	var rowNum=getRowNumFromName($(control_obj).parent().attr('id'));
	var sizeSystem=$('#value_'+size_type_control+'_'+rowNum).val();
	var breakupJsonString="";
	if(sizeSystem){
	//if($('#addSizebreakupdialog_'+rowNum).html()==null){
	if($('#sizebreakupvalues['+rowNum+']').val()!=''){
		breakupJsonString=$('#sizebreakupvalues['+rowNum+']').val();
		}else{
		  $(control_obj).parent().append('<input id="sizebreakupvalues['+rowNum+']" type=Hidden value=""/>');
		}
		
		$.ajax({
		  url: "php/getsizebreakupdialog.php",
		  data: "system="+sizeSystem+"&rownum="+rowNum+"&breakupDefault="+breakupJsonString,
		  success: function(data){
		 $(data).dialog({buttons: { "Ok": function() { placeSizebreakuponParent(rowNum,this) }, "Cancel": function() { $(this).dialog("close"); } }, modal: true, overlay: { opacity: 0.5, background: "black" } });
		  }
		});
		// }
		// else{
			// $($('#addSizebreakupdialog_'+rowNum).html()).dialog({buttons: { "Ok": function() { placeSizebreakuponParent(rowNum);$(this).dialog("close"); }, "Cancel": function() { $(this).dialog("close"); } }, modal: true, overlay: { opacity: 0.5, background: "black" } });
		// }

	}
else
	{
		alert("Please select size system");
	}
}
function getRowNumFromName(control_id){
	var control_id=control_id.split('_');
	return control_id[0].replace('edit','');
}
function calculateSizeBreakupTotal(class_name){
 $("."+class_name).each(function() {
            $(this).keyup(function(){
                calculateSum(class_name);
            });
        });
}
function calculateSum(class_name) {
        var sum = 0;
        //iterate through each textboxes and add the values
        $("."+class_name).each(function() {
 
            //add only if the value is number
            if(!isNaN(this.value) && this.value.length!=0) {
                sum += parseFloat(this.value);
            }
 
        });
        //.toFixed() method will roundoff the final sum to 2 decimal places
        $("#total_"+class_name).html(sum.toFixed(0));
    }
	
	function placeSizebreakuponParent(rowNum,dialogObj){
	var breakupJsonString="{";
	$(".size_breakup_4").each(function(){
	var breakupCount=$(this).attr('id').split('_');
	breakupJsonString+=breakupCount[2]+":"+$(this).val()+",";
	
	});
	breakupJsonString=breakupJsonString.slice(0,-1);
	breakupJsonString+="}";
	$('#sizebreakupvalues['+rowNum+']').val(breakupJsonString);
	$(dialogObj).dialog("close");
	}